﻿dojo.addOnLoad(
  function () {
      hideAllPanel()
      document.getElementById("Panel1").style.display = "";
      unselectAllButton();
      AttachEvent();
      sistemaFaceLike();
      document.getElementById("Selector1").style.backgroundImage = "url(../Styles/Images/button98x46.png)"

      document.getElementById("Selector1").onclick = function () {
          unselectAllButton()
          document.getElementById("Selector1").style.backgroundImage = "url(../Styles/Images/button98x46.png)"
          hideAllPanel()
          document.getElementById("Panel1").style.display = "";
          sistemaFaceLike();
      }
      document.getElementById("Selector2").onclick = function () {
          unselectAllButton()
          document.getElementById("Selector2").style.backgroundImage = "url(../Styles/Images/button98x46.png)"
          hideAllPanel()
          document.getElementById("Panel2").style.display = "";
          sistemaFaceLike();
      }
      document.getElementById("Selector3").onclick = function () {
          unselectAllButton()
          document.getElementById("Selector3").style.backgroundImage = "url(../Styles/Images/button98x46.png)"
          hideAllPanel()
          document.getElementById("Panel3").style.display = "";
          sistemaFaceLike();
      }
      document.getElementById("Selector4").onclick = function () {
          unselectAllButton()
          document.getElementById("Selector4").style.backgroundImage = "url(../Styles/Images/button98x46.png)"
          hideAllPanel()
          document.getElementById("Panel4").style.display = "";
          sistemaFaceLike();
      }
      document.getElementById("Selector5").onclick = function () {
          unselectAllButton()
          document.getElementById("Selector5").style.backgroundImage = "url(../Styles/Images/button98x46.png)"
          hideAllPanel()
          document.getElementById("Panel5").style.display = "";
          sistemaFaceLike();
      }
      document.getElementById("Selector6").onclick = function () {
          unselectAllButton()
          document.getElementById("Selector6").style.backgroundImage = "url(../Styles/Images/button98x46.png)"
          hideAllPanel()
          document.getElementById("Panel6").style.display = "";
          sistemaFaceLike();
      }
      document.getElementById("Selector7").onclick = function () {
          unselectAllButton()
          document.getElementById("Selector7").style.backgroundImage = "url(../Styles/Images/button98x46.png)"
          hideAllPanel()
          document.getElementById("Panel7").style.display = "";
          sistemaFaceLike();
      }
      hideAllItemTemplate()


  })

  function sistemaFaceLike() {
    dojo.query("iframe[class='fb_ltr']").forEach(function(tagElement) {
      tagElement.src= tagElement.src.replace("&width=450","") })
}

function SelectDay() {
    document.getElementById("Panel1").style.display = "none";
    document.getElementById("Selector1").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
    var Today = new Date()
    Today = Today.getDay()
    if (Today == 0)
        Today = 7
    document.getElementById("Panel" + Today).style.display = "";
    document.getElementById("Selector" + Today).style.backgroundImage = "url(../Styles/Images/button98x46.png)"
}

function unselectAllButton() {
    document.getElementById("Selector1").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
    document.getElementById("Selector2").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
    document.getElementById("Selector3").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
    document.getElementById("Selector4").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
    document.getElementById("Selector5").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
    document.getElementById("Selector6").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
    document.getElementById("Selector7").style.backgroundImage = "url(../Styles/Images/buttonGray98x46.png)"
}

function hideAllPanel() {
    document.getElementById("Panel1").style.display = "none";
    document.getElementById("Panel2").style.display = "none";
    document.getElementById("Panel3").style.display = "none";
    document.getElementById("Panel4").style.display = "none";
    document.getElementById("Panel5").style.display = "none";
    document.getElementById("Panel6").style.display = "none";
    document.getElementById("Panel7").style.display = "none";
}

function hideAllItemTemplate() {

    dojo.query("[id*='ItemTemplate_']").forEach(function(tagElement) {
        tagElement.style.display="none";
    });

}

function ShowHide(evt) {
    var divElementName = evt.currentTarget.id.replace("ImageApri", "ItemTemplate")
    dojo.query("[id='" + divElementName + "']").forEach(function(tagElement) {
        if(tagElement.style.display == "none") {
            tagElement.style.display = ""
            evt.currentTarget.childNodes[1].src = "../Styles/Images/Minus.png"
           
        }
        else
        {
            tagElement.style.display = "none"
            evt.currentTarget.childNodes[1].src = "../Styles/Images/Plus.png"
          
        }
    })
}

function AttachEvent() {
    dojo.query("div[id*='ImageApri_']").forEach(function (tagElement) {
        dojo.connect(tagElement, "onclick", null, "ShowHide");
    });
}